﻿using System.Threading.Tasks;

namespace Database.infrastructure
{
    /// <summary>
    /// 提交数据操作
    /// </summary>
    public class UnitOfWork : IUnitOfWork
    {
        private readonly IDatabaseFactory _databaseFactory;

        public UnitOfWork(IDatabaseFactory databaseFactory)
        {
            _databaseFactory = databaseFactory;
        }

        public int Commit()
        {
            return _databaseFactory._dbContext.SaveChanges();
        }

        public Task<int> CommitAsync()
        {
            return _databaseFactory._dbContext.SaveChangesAsync();
        }
    }
}